/**
 * Apr 3, 2010
 */
package org.tomale.id.gis.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.tomale.id.gis.Activator;
import org.tomale.id.gis.ui.MapEditor;
import org.tomale.id.gis.ui.MapEditorInput;

/**
 * @author ferd
 *
 */
public class ShowMapEditor extends AbstractHandler {

	/* (non-Javadoc)
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		try {
			IEditorPart part = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new MapEditorInput(), MapEditor.EDITOR_ID);
			return part;
		}catch(PartInitException e){
			throw new ExecutionException("Unable to create map editor.",e);
		}
	}

}
